# -*- coding: utf-8 -*-
# Copyright © 2015 Beijing HengXingChangDa Technology Co., Ltd. All rights reserved.


class Error:
    def __init__(self, code):
        self.code = code
        self.msg = dict()

    def set_msg(self, locale, msg):
        self.msg[locale] = msg

    def to_dict(self, locale='CN', add_msg=None):
        d = dict()
        d['Code'] = self.code
        d['Message'] = self.msg[locale]
        if add_msg:
            d['Message'] = d['Message'] + add_msg
        return d

    def get_msg(self, locale='CN'):
        return self.msg[locale]


class ErrorSet:
    errors = []
    error_num = 0

    def __init__(self):
        pass

    @staticmethod
    def add_error(error):
        ErrorSet.errors.append(error)
        ErrorSet.error_num += 1
